import { post } from '@/request/http'
import { setMd5 } from '@/utils/utils'
import store from '@/store'

//区域中心创建/维护接口

// 左边树形结构数据
export const regionalCenterLeft = () =>
  post(
    '/FTKJWLHYPT/platform/getChildrenDptList',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            dptFltId:store.state.user.FLT_UUID_DX_H,
          }
        },
      }
    }
  )

// 右边列表查询接口
export const regionalCenterRightList = (data) =>
  post(
    '/FTKJWLHYPT/platform/getUsers',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            usrEtpId:store.state.user.FLT_UUID_DX_H,
            usrCode:data.usrCode,
            usrDpts:data.usrDpts
          }
        },
        Orderbys: {},
        PageIndexs: {
          FTKJWLHYPT: data.PageIndexs
        },
        PageSizes: {
          FTKJWLHYPT:data.PageSizes
        }
      }
    }
  )

// 新增
export const addRegionalCenterRightList = ({
  usrRles,
  // usrEtpId,
  usrCode,
  usrName,
  usrPassword,
  usrCellphone,
  usrEmail,
  usrPreuserId,
  usrStatus,
  usrX,
  usrY,
  usrRemark,
  roleList,
  usrDpts,
  usrType
}) =>
  post(
    '/FTKJWLHYPT/platform/addUser',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            usrRles: usrRles.join(','),
            usrEtpId:store.state.user.FLT_UUID_DX_H,
            usrCode,
            usrName,
            usrPassword: setMd5(usrPassword),
            usrCellphone,
            usrEmail,
            usrPreuserId,
            usrStatus,
            usrX,
            usrY,
            usrRemark,
            roleList,
            usrDpts,
            usrType
          },
        },
      }
    }
  )

// 编辑
export const editRegionalCenterRightList = ({
  usrId,
  // usrEtpId,
  usrCode,
  usrName,
  usrPassword,
  usrCellphone,
  usrEmail,
  usrPreuserId,
  usrStatus,
  usrX,
  usrY,
  usrRemark,
  roleList,
  usrDpts,
  usrType,
  usrRles
}) =>
  post(
    '/FTKJWLHYPT/platform/editUser',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            usrRles: usrRles.join(','),
            usrId,
            usrEtpId:store.state.user.FLT_UUID_DX_H,
            usrCode,
            usrName,
            usrPassword,
            usrCellphone,
            usrEmail,
            usrPreuserId,
            usrStatus,
            usrX,
            usrY,
            usrRemark,
            roleList,
            usrDpts,
            usrType,
          },
        },
      }
    }
  )

//角色数据
export const RegionalCenterJS = () =>
  post(
    '/FTKJWLHYPT/platform/queryRole',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {

          }
        },
      }
    }
  )

//区域中心
export const RegionalCenterzx = () =>
  post(
    '/FTKJWLHYPT/platform/getChildrenDptList',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            dptFltId:store.state.user.FLT_UUID_DX_H
          }
        },
      }
    }
  )

// 删除
export const eitregionalCenter = (data) =>
  post(
    '/FTKJWLHYPT/platform/deleteUser',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            usrId:data.usrId,
          }
        },
      }
    }
  )

// 密码重置
export const czregionalCenter = (data) =>
  post(
    '/FTKJWLHYPT/resetPassword',
    {
      Data: {
        Parameters: {
          FTKJWLHYPT: {
            usrId:data.usrId,
          }
        },
      }
    }
  )
